import { createSSRApp } from "vue";
import App from "./App.vue";
import store from './store'
import router from './router'
import theme from './theme'
import http from './utils/http'
import util from './utils/index'
import i18n from './language/index';

import 'vue-global-api'
export function createApp() {
  const app = createSSRApp(App);
  app.config.globalProperties.$Router = router;
  app.config.globalProperties.$Route = router.route;
  app.config.globalProperties.$http = http;
  app.config.globalProperties.$util = util;
  uni.getSystemInfo({
    success: function(e) {
      app.config.globalProperties.SystemInfo = e;
      app.config.globalProperties.isPhone = e.platform == 'ios' || e.platform == 'android' || e.platform == 'devtools';
      // #ifndef MP
      app.config.globalProperties.StatusBar = (e.statusBarHeight == undefined ? 0 : e.statusBarHeight);
      if (e.platform == 'android') {
        app.config.globalProperties.CustomBar = app.config.globalProperties.StatusBar + 50;
      } else {
        app.config.globalProperties.CustomBar = app.config.globalProperties.StatusBar + 45;
      }
      // #endif
      // #ifdef MP-WEIXIN
      app.config.globalProperties.StatusBar = e.statusBarHeight;
      let custom = uni.getMenuButtonBoundingClientRect();
      app.config.globalProperties.Custom = custom;
      app.config.globalProperties.CustomBar = custom.bottom + custom.top - app.config.globalProperties.StatusBar;
      // #endif
      // #ifdef MP-ALIPAY
      app.config.globalProperties.StatusBar = e.statusBarHeight;
      app.config.globalProperties.CustomBar = app.config.globalProperties.StatusBar + (e.titleBarHeight == undefined ? 0 : e.titleBarHeight);
      // #endif
    }
  });
	app.config.globalProperties.$theme = theme
	app.config.globalProperties.$themeClass = theme.themeClass
  app.use(store)
  app.use(i18n);
  return {
    app,
  };
}
